package com.example.base.net

import com.example.base.entity.*
import okhttp3.RequestBody
import retrofit2.http.Body
import retrofit2.http.GET
import retrofit2.http.POST
import retrofit2.http.Path
import retrofit2.http.Query

interface ApiService {
    @POST(Cons.LOGIN_CODE_URL)
    suspend fun loginCode(@Body body: RequestBody): LoginEntityResult

    @POST(Cons.SEND_CODE_URL)
    suspend fun sendCode(@Query("phone") phone: String): SendCodeEntityResult

    @POST(Cons.PASSWORD_URL)
    suspend fun password(@Body body: RequestBody): PasswordEntityResult

    @POST(Cons.LOGIN_URL)
    suspend fun login(@Body body: RequestBody): LoginEntityResult

    //首页数据
    @GET(Cons.INDEX_URL)
    suspend fun index(): IndexEntityResult

    @GET(Cons.INDEX_GOODS_URL)
    suspend fun indexGoods(
        @Path("type") type: Int,
        @Query("limit") limit: Int,
        @Query("page") page: Int
    ): GoodsEntityResult

    @GET(Cons.SEARCH_URL)
    suspend fun search(
        @Query("cid") cid: Int,
        @Query("keyword") keyword: String,
        @Query("limit") limit: Int,
        @Query("news") news: Boolean,
        @Query("page") page: Int,
        @Query("priceOrder") priceOrder: String,
        @Query("salesOrder") salesOrder: String
    ): GoodsEntityResult
    @GET(Cons.CATEGORY_URL)
    suspend fun category():CategoryEntityResult
    @GET(Cons.DETAIL_URL)
    suspend fun detail(@Path("id")id:Int,@Query("type")type:String):DetailEntityResult

    @POST(Cons.ADDCAR_URL)
    suspend fun addCar(@Body body: RequestBody):AddCarEntityResult
    @GET(Cons.GETCAR_URL)
    suspend fun getCar(@Query("isValid")isValid:String,@Query("page")page:String,@Query("limit")limit:String):CarEntityResult
    @POST(Cons.UPDATECAR_URL)
    suspend fun updateCar(@Query("id")id:Int,@Query("number")number:Int):UpdateCarEntityResult
    @POST(Cons.DELETECAR_URL)
    suspend fun deleteCar(@Query("ids")ids:ArrayList<Int>):DeleteCarEntityResult
}